Skip to content

Conversation

@yger
Copy link
Collaborator

@yger yger commented Jan 8, 2026

After playing with real-size datasets during the hackathon amazingly organized by our "ami du bouchon" @samuelgarcia , I realized, that some persons might consider spikeinterface too slow. And because we want everyong to join the game (the more the merrier), we need to be inclusive. During the hackthon, we've worked to solve the problem with cross-correlograms (see #4305 and #4307 ). However, we might wonder what can be done for the other metrics, and to do so, first thing is to time the metric. This is what is now added by the PR

For a 1000s recording with 1000 units, you can immediatly see some issues, and they are all fixed in this PR. Some metrics, for example, are using suboptimal correlograms (numpy implemetantations), and some others I guess should be optimized. Before, we used to have

{'num_spikes': 21.245169458998134,
'firing_rate': 0.0007224159999168478,
'presence_ratio': 0.14417108400084544,
'snr': 0.040033251003478654,
'isi_violation': 0.049835821002488956,
'rp_violation': 3.409717330003332,
'sliding_rp_violation': 7.334715744997084,
'synchrony': 21.48789839699748,
'firing_range': 0.36698940899805166,
'amplitude_cv': 28.745208095002454,
'amplitude_cutoff': 0.5351223960024072,
'noise_cutoff': 0.8977982619981049,
'amplitude_median': 0.4023318469990045,
'sd_ratio': 48.09409817199776}

With the PR, we now have:

  • {'num_spikes': 0.12104277299658861}
  • {'sd_ratio': 2.566413887994713}
  • {'amplitude_cv': 4.915091472001222,
  • {'rp_violation': 1.7641781819984317}
  • {'sliding_rp_violation': 4.426980464999797}
  • {'synchrony': 7.823143080997397}

Plus, now rp_violation accepts a unit_ids to avoid recomputations during slices. I'm fairly happy with the PR as it is. It can also be boosted with speed up in CCG. I've also ported the optimizaiton to the drift metric, now really fast

  • {drift': 5.542134855990298}

@yger yger marked this pull request as draft January 8, 2026 17:58
@alejoe91 alejoe91 added the metrics Related to metrics module label Jan 9, 2026
@samuelgarcia
Copy link
Member

Pierre notre héros.

@samuelgarcia
Copy link
Member

I realized, that some persons might consider spikeinterface too slow.

No name please.

@samuelgarcia
Copy link
Member

I would also consider that slow computation should be removed of the by default metrics.
No ?

@yger
Copy link
Collaborator Author

yger commented Jan 9, 2026

This looks good to me, I've checked the results are the same, and I've drastically reduce the cost of the most important ones. The only remaining extension that is slow is the synchrony, but not sure to understand exactly what it does. Is people needing it? Are also people using the metrics for the drifts @alejoe91 ? Because they could be optimized also

@yger
Copy link
Collaborator Author

yger commented Jan 9, 2026

And also, there is something strange, i think, in the implementation of sliding_rpv_violations. At least, this is not what I would have done, and I'm not sure this is also exactly what the authors meant to do, but I could be wrong, I need to read more the paper to double check. I made an implementation that keep results the same (but can gain numba implementation of correlograms, and eventually also of the fast mode available in #4305 )

@yger yger marked this pull request as ready for review January 9, 2026 16:31
@yger
Copy link
Collaborator Author

yger commented Jan 11, 2026

@alejoe91 I've also drastically improve the drift metric. @alejoe91 @samuelgarcia @chrishalcrow let me know what do you think, but this is now good for me. All metrics have been heavily optimized using the spike vector, and they are much faster now

@yger
Copy link
Collaborator Author

yger commented Jan 11, 2026

On real-world data from the IBL, 1140 units for 1000s with ~ 38 millions spikes, the computations of all metrics (including drift) goes from 320 second seconds to only 84 secons with this PR on my laptop. So a x4 speedup, at least, with identical results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

metrics Related to metrics module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants